﻿@model GridMvc.Pagination.GridPager

@if (Model == null)
{
    return;
}

<div class="summary">
    <div class="dataTables_info">
        Showing @((Model.CurrentPage * Model.PageSize) - Model.PageSize + 1)
        to @((Model.CurrentPage * Model.PageSize) > Model.ItemsCount ? Model.ItemsCount : (Model.CurrentPage * Model.PageSize))
        of @Model.ItemsCount entries
    </div>
</div>

@if (Model.PageCount <= 1)
{
    return;
}

<div class="dataTables_paginate paging_full_numbers">
    @if (Model.CurrentPage > 1)
    {
        <a class="first paginate_button" href="@Model.GetLinkForPage(1)">First</a>
    }
    @if (Model.CurrentPage > 1)
    {
        <a class="previous paginate_button" href="@Model.GetLinkForPage(Model.CurrentPage - 1)">Prev</a>
    }

    @if (Model.StartDisplayedPage > 1)
    {
        <a class="paginate_button" href="@Model.GetLinkForPage(1)">1</a>
        if (Model.StartDisplayedPage > 2)
        {
            <a class="paginate_button" href="@Model.GetLinkForPage(Model.StartDisplayedPage - 1)">...</a>
        }
    }
    @for (int i = Model.StartDisplayedPage; i <= Model.EndDisplayedPage; i++)
    {
        if (i == Model.CurrentPage)
        {
            <a class="paginate_button paginate_button_disabled" href="javascript:;">@i</a>
        }
        else
        {
            <a class="paginate_button" href="@Model.GetLinkForPage(i)">@i</a>
        }
    }
    @if (Model.EndDisplayedPage < Model.PageCount)
    {
        if (Model.EndDisplayedPage < Model.PageCount - 1)
        {
            <a class="paginate_button pager_summary" href="@Model.GetLinkForPage(Model.EndDisplayedPage + 1)">...</a>
        }
        <a class="paginate_button" href="@Model.GetLinkForPage(Model.PageCount)">@Model.PageCount</a>
    }
    @if (Model.CurrentPage < Model.PageCount)
    {
        <a class="next paginate_button" href="@Model.GetLinkForPage(Model.CurrentPage + 1)">Next</a>
    }
    @if (Model.CurrentPage < Model.PageCount)
    {
        <a class="Last paginate_button" href="@Model.GetLinkForPage(Model.PageCount)">Last</a>
    }
</div>
